export let search = {
    namespaced: true,
    state: {
        search_data: [],
        search_flag: false
    },
    actions: {
        getSearchData(store, data = {}) {
            let url = "/search/query/" + data.keyword + "/category/" + data.range + "/count/" + data.count + "/page/" + data.page;
            axios.get(url).then(({
                data
            }) => {
                let list = [];
                for (const key in data.results) {
                    if (data.results.hasOwnProperty(key)) {
                        const element = data.results[key];
                        list.push(element.desc)
                    }
                }
                store.commit("setSearchData", list)
            });
        }
    },
    mutations: {
        setSearchData(state, data) {
            state.search_data = data;
            state.search_flag = true;
        }
    }
}